import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
import { BaseItem } from "../../common/BaseItem";
import { SPlayerItem } from "../../../../../Message/Public/SPlayerItem";
import { ItemData } from "../../../resource/info/ItemData";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class GuildAnimalGetItemsWindow
    
    export  class GuildAnimalGetItemsWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._baseItems = [];
            this.setSize(340, 200);
            this.titleHeight = 28;
            this.title = Language.getString(57533);
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=null;
            var loc2=0;
            super.createChildren();
            ObjCreate.createBg(19, 40, 305, 115, this);
            ObjCreate.createTextField(Language.getString(57535), 30, 50, 220, 20, this, GlobalStyle.textFormat6);
            loc2 = 0;
            while (loc2 < 4) 
            {
                ObjCreate.createBg(33 + loc2 * 70, 78, 65, 65, this, ImagesConst.PackItemBg);
                loc1 = new BaseItem();
                loc1.isDragAble = false;
                loc1.isShowLock = true;
                loc1.setSize(59, 59);
                loc1.x = 35 + loc2 * 70;
                loc1.y = 80;
                loc1.setAmountLabelPos(0, 40);
                this.addChild(loc1);
                this._baseItems.push(loc1);
                ++loc2;
            }
            this._getBtn = ObjCreate.createGButton(Language.getString(57534), 133, 160, 70, 28, this);
            this._getBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onGetBtnClickHandler);
            return;
        }

        public updateByItems(arg1: Array<any>): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            while (loc4 < 4) 
            {
                loc3 = this._baseItems[loc4] as BaseItem;
                loc1 = arg1[loc4] as SPlayerItem;
                if (loc1) 
                {
                    loc2 = new ItemData(loc1);
                }
                else 
                {
                    loc2 = null;
                }
                loc3.itemData = loc2;
                ++loc4;
            }
            return;
        }

        /* internal  */onGetBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildAnimalGetItem));
            return;
        }

        /* internal  */test(): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 4) 
            {
                loc1 = this._baseItems[loc2] as BaseItem;
                loc1.itemData = new ItemData(14055300);
                loc1.amount = 5;
                ++loc2;
            }
            return;
        }

        /* internal */ /* var */_getBtn: GButton;

        /* internal */ /* var */_baseItems: Array<any>;
    }
